import type { App } from 'vue';
import { createRouter, createWebHistory } from 'vue-router';
import { whiteNameList } from './constant';
import { createRouterGuards } from './routerGuards';
import { routes } from './routes';

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [...routes],
});

export default router;

const setupRouter = (app: App) => {
  createRouterGuards(router, whiteNameList);

  app.use(router);
};

export { setupRouter };
